package com.ravi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ravi.dao.CheckPlanDAO;
import com.ravi.entity.CheckPlan;
import com.ravi.vo.PlanItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CheckPlanService {

	@Autowired
	private CheckPlanDAO checkPlanDAO;

	/**
	 * 返回所有的套餐
	 * @return List<CheckPlan>
	 */
	public PageInfo<CheckPlan> listAllPlans(Integer pageNum, Integer pageSize) {
		PageHelper.startPage(pageNum, pageSize, "plan_id");
		List<CheckPlan> planList = checkPlanDAO.selectAllPlans();
		return new PageInfo<>(planList);
	}

	/**
	 * 返回某个套餐信息及所有项目基本信息
	 * @param planId 套餐id
	 * @return PlanItemVo 套餐信息 + 项目列表
	 */
	public PlanItemVo listItemListForOnePlan(Integer planId) {
		return checkPlanDAO.selectPlanItemListById(planId);
	}
}
